//
//  ToBeReviewedTaskDetailViewController.m
//  MyProject
//
//  Created by Pei on 16/7/18.
//  Copyright © 2016年 Xiaobo Pei. All rights reserved.
//

#import "ToBeReviewedTaskDetailViewController.h"
#import "ToBeReviewedTaskDetailCell.h"
#import "WriteToBeReviewedTaskViewController.h"
#import "UserInfo.h"
#import "ToBeReviewedTaskListViewController.h"

@interface ToBeReviewedTaskDetailViewController ()<UITableViewDelegate, UITableViewDataSource, WriteToBeReviewedTaskViewControllerDelegate>
{
    NSDictionary *_currentDic;
    NSString *_currentStr;
    
    UITableView *_myTable;
    
    NSDictionary *_dataDic;
    
    UIView *_footView;
    
    NSArray *bottomList;
}
@end

@implementation ToBeReviewedTaskDetailViewController

- (id)initWithDicFrom:(NSString*)InspectionIDStr InspectionItemID:(NSString*)InspectionItemIDStr{
    self = [super init];
    if (self) {
        [[YMNetLib getInstance] connectWithAction:Get_ToBeReviewed_Task_Detail method:@"GET" withContent:[NSString stringWithFormat:@"InspectionID=%d&InspectionItemID=%d",[InspectionIDStr intValue],[InspectionItemIDStr intValue]] withBody:nil withDelegate:self];
        _currentStr = Get_ToBeReviewed_Task_Detail;
    }
    return self;
}

- (id)initWithDic:(NSDictionary*)dic{
    self = [super init];
    if (self) {
        _currentDic = dic;
        [self getData];
    }
    return self;
}


- (void)getData
{
    //Get_ToBeSure_Task_Detail
    [[YMNetLib getInstance] connectWithAction:Get_ToBeReviewed_Task_Detail method:@"GET" withContent:[NSString stringWithFormat:@"InspectionID=%d&InspectionItemID=%d",[[_currentDic valueForKey:@"InspectionID"] intValue],[[_currentDic valueForKey:@"InspectItemID"] intValue]] withBody:nil withDelegate:self];
    _currentStr = Get_ToBeReviewed_Task_Detail;
}

- (void)getRepairRecordState
{
    //Dic_RepairRecordState
    [[YMNetLib getInstance] connectWithAction:Dictionary_Type_API method:@"GET" withContent:@"DicType=RepairRecordState" withBody:nil withDelegate:self];
    _currentStr = @"Dic_RepairRecordState";
}

- (void)NetDoOverSuccess:(NSDictionary*)body
{
    if ([_currentStr isEqualToString:Get_ToBeReviewed_Task_Detail]) {
        if ([[YMNetDataUtil getSuccessState:body] intValue] == 1)
        {
            _dataDic = body;
            
            bottomList = [_dataDic objectForKey:@"InspectTaskList"];
            
            [self initTable];
            //[self initFooter];
            
//            NSArray *tempArray = [[NSUserDefaults standardUserDefaults] objectForKey:Check_Type_Items];
//            if (tempArray != nil && tempArray.count > 0) {
//                
//            }else{
                [self getCheckData];
//            }
            
            
//            NSArray *arrayT = [[NSUserDefaults standardUserDefaults] objectForKey:select_RiskLevel];
//            if (arrayT != nil && arrayT.count > 0) {
//            }else{
//                [self getLevelData];
//            }
            
//            NSArray *tempI = [[NSUserDefaults standardUserDefaults] objectForKey:Dic_AuditState];
//            if (tempI != nil && tempI.count > 0) {
//                
//            }else{
//                //AuditState
//                [[YMNetLib getInstance] connectWithAction:Dictionary_Type_API method:@"GET" withContent:@"DicType=AuditState" withBody:nil withDelegate:self];
//                _currentStr = @"Dic_AuditState";
//                
//            }
            
//            NSArray *arrayYYY = [[NSUserDefaults standardUserDefaults] objectForKey:Dic_RepairRecordState];
//            if (arrayYYY != nil && arrayYYY.count > 0) {
//            }else{
//                [self getRepairRecordState];
//            }
            
            [_myTable reloadData];
            
        }
    }else if ([_currentStr isEqualToString:@"Check_Type_Items"]){
        if ([[YMNetDataUtil getSuccessState:body] intValue] == 1)
        {
            [[NSUserDefaults standardUserDefaults] setObject:[body valueForKey:@"DicList"] forKey:Check_Type_Items];
            [_myTable reloadData];
            
//            NSArray *arrayT = [[NSUserDefaults standardUserDefaults] objectForKey:select_RiskLevel];
//            if (arrayT != nil && arrayT.count > 0) {
//            }else{
                [self getLevelData];
//            }

        }
        
    }else if ([_currentStr isEqualToString:@"select_RiskLevel"]){
        if ([[YMNetDataUtil getSuccessState:body] intValue] == 1){
            [[NSUserDefaults standardUserDefaults] setObject:[body valueForKey:@"DicList"] forKey:select_RiskLevel];
            [_myTable reloadData];
            
//            NSArray *tempI = [[NSUserDefaults standardUserDefaults] objectForKey:Dic_AuditState];
//            if (tempI != nil && tempI.count > 0) {
//                
//            }else{
                //AuditState
//                [[YMNetLib getInstance] connectWithAction:Dictionary_Type_API method:@"GET" withContent:@"DicType=AuditState" withBody:nil withDelegate:self];
//                _currentStr = @"Dic_AuditState";
            [self getAuditStateData];
//            }

        }
        
    }else if ([_currentStr isEqualToString:@"Dic_AuditState"]){
        if ([[YMNetDataUtil getSuccessState:body] intValue] == 1){
            NSLog(@"Dic_AuditState%@", [body description]);
            [[NSUserDefaults standardUserDefaults] setObject:[body valueForKey:@"DicList"] forKey:Dic_AuditState];
            [_myTable reloadData];
            
//            NSArray *arrayYYY = [[NSUserDefaults standardUserDefaults] objectForKey:Dic_RepairRecordState];
//            if (arrayYYY != nil && arrayYYY.count > 0) {
//            }else{
                [self getRepairRecordState];
//            }

        }
        
    }else if ([_currentStr isEqualToString:Get_AuditRepairRecord]){
        if ([[YMNetDataUtil getSuccessState:body] intValue] == 1){
            if ([[YMNetDataUtil getSuccessState:body] intValue] == 1){
                for (UIViewController *temp in self.navigationController.viewControllers) {
                    if ([temp isKindOfClass:[ToBeReviewedTaskListViewController class]]) {
                        [self.navigationController popToViewController:temp animated:YES];
                    }
                }
            }
            [[NSNotificationCenter defaultCenter] postNotificationName:@"Reload_ToBeReviewed_LIst" object:nil];
        }
        
    }
        
    if ([_currentStr isEqualToString:@"Dic_RepairRecordState"]){
        if ([[YMNetDataUtil getSuccessState:body] intValue] == 1){
            [[NSUserDefaults standardUserDefaults] setObject:[body valueForKey:@"DicList"] forKey:Dic_RepairRecordState];
            [[NSUserDefaults standardUserDefaults] synchronize];
            [_myTable reloadData];
        }
    }
    
//    else{
//        if ([[YMNetDataUtil getSuccessState:body] intValue] == 1)
//        {
//            NSLog(@"KKKKKKKKK");
//        }
//    }
}

- (void)getAuditStateData{
    [[YMNetLib getInstance] connectWithAction:Dictionary_Type_API method:@"GET" withContent:@"DicType=AuditState" withBody:nil withDelegate:self];
    _currentStr = @"Dic_AuditState";
}

- (void)getLevelData{
    [[YMNetLib getInstance] connectWithAction:Dictionary_Type_API method:@"GET" withContent:@"DicType=RiskLevel" withBody:nil withDelegate:self];
    _currentStr = @"select_RiskLevel";
}

- (void)getCheckData{
    [[YMNetLib getInstance] connectWithAction:Dictionary_Type_API method:@"GET" withContent:@"DicType=InspectType" withBody:nil withDelegate:self];
    _currentStr = @"Check_Type_Items";
}



- (void)viewDidLoad {
    self.navTitle = @"审批详情";
    [super viewDidLoad];
}

- (void)initTable
{
    _myTable = [[UITableView alloc] init];
    _myTable.frame = CGRectMake(0.0f, 0.0f, kDeviceWidth, kDeviceHeight-NAV_HEIGHT);
    _myTable.delegate = self;
    _myTable.dataSource = self;
    _myTable.backgroundColor = kRGB(241, 246, 250);
    _myTable.tableFooterView = [UIView new];
    [self.view addSubview:_myTable];
}

- (void)initFooter
{
    
    _footView = [[UIView alloc] init];
    _footView.frame = CGRectMake(0.0f, self.view.height-54.0f, kDeviceWidth, 54.0f);
    _footView.backgroundColor = kWhiteColor;
    [self.view addSubview:_footView];
    
    
    
    UIButton *seeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    seeBtn.frame = CGRectMake(16.0f, (54.0f-40.0f)/2.0f, (kDeviceWidth-16*4)/3.0f, 40.0f);
    [seeBtn setBackgroundColor:kRGB(113, 122, 162)];
    [seeBtn setTitle:@"查看" forState:UIControlStateNormal];
    seeBtn.layer.cornerRadius = 5.0f;
    seeBtn.layer.masksToBounds = YES;
    seeBtn.tag = 116;
    [seeBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
    [_footView addSubview:seeBtn];
    
    UIButton *passBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    passBtn.frame = CGRectMake(seeBtn.right+16.0f, (54.0f-40.0f)/2.0f, (kDeviceWidth-16*4)/3.0f, 40.0f);
    [passBtn setBackgroundColor:kBlueColor];
    [passBtn setTitle:@"通过" forState:UIControlStateNormal];
    passBtn.layer.cornerRadius = 5.0f;
    passBtn.layer.masksToBounds = YES;
    passBtn.tag = 118;
    [passBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
    [_footView addSubview:passBtn];
    
    
    UIButton *refuseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    refuseBtn.frame = CGRectMake(passBtn.right+16.0f, (54.0f-40.0f)/2.0f, (kDeviceWidth-16*4)/3.0f, 40.0f);
    [refuseBtn setBackgroundColor:kRedColor];
    [refuseBtn setTitle:@"拒绝" forState:UIControlStateNormal];
    refuseBtn.layer.cornerRadius = 5.0f;
    refuseBtn.layer.masksToBounds = YES;
    refuseBtn.tag = 119;
    [refuseBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
    [_footView addSubview:refuseBtn];
}


- (void)btnAction:(UIButton*)sender
{
    switch (sender.tag) {
        case 116:
        {
            
        }
            break;
        case 118:
        {
            NSArray *listA = [_dataDic objectForKey:@"InspectTaskList"];
            NSDictionary *kkkk;
            if (listA != nil && listA.count>0) {
                kkkk = [listA objectAtIndex:0];
            }
            NSDictionary *bodyD = [NSDictionary dictionaryWithObjectsAndKeys:
                                   [[UserInfo getInstance] getUserID],@"UserID",
                                   [NSNumber numberWithInt:[[_dataDic valueForKey:@"InspectionID"] intValue]],@"InspectionID",
                                   [NSNumber numberWithInt:[[kkkk valueForKey:@"InspectTaskID"] intValue]],@"InspectTaskID",
                                   @"",@"DeadLine",
                                   @"",@"AuditDesc",
                                   [NSNumber numberWithInt:0],@"AuditResult",//0通过 1 拒绝
                                   nil];
            [[YMNetLib getInstance] connectWithAction:Get_AuditRepairRecord method:@"POST" withContent:@"" withBody:bodyD withDelegate:self];
            _currentStr = Get_AuditRepairRecord;
        }
            break;
        case 119:
        {
            NSArray *listA = [_dataDic objectForKey:@"InspectTaskList"];
            NSDictionary *kkkk;
            if (listA != nil && listA.count>0) {
                kkkk = [listA objectAtIndex:0];
            }
            NSDictionary *bodyD = [NSDictionary dictionaryWithObjectsAndKeys:
                                   [[UserInfo getInstance] getUserID],@"UserID",
                                   [NSNumber numberWithInt:[[_dataDic valueForKey:@"InspectionID"] intValue]],@"InspectionID",
                                   [NSNumber numberWithInt:[[kkkk valueForKey:@"InspectTaskID"] intValue]],@"InspectTaskID",
                                   @"",@"DeadLine",
                                   @"",@"AuditDesc",
                                   [NSNumber numberWithInt:1],@"AuditResult",//0通过 1 拒绝
                                   nil];
            [[YMNetLib getInstance] connectWithAction:Get_AuditRepairRecord method:@"POST" withContent:@"" withBody:bodyD withDelegate:self];
            _currentStr = Get_AuditRepairRecord;
            
        }
            break;
            
        default:
            break;
    }
}

#pragma mark  ************************* UITableViewDataSource **************************************
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 7.0f;
    }else{
        NSArray *listA = [_dataDic objectForKey:@"InspectTaskList"];
        return listA.count;
    }
    return 0.0f;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0){
        static NSString *identifier = @"cell_house_History";
        UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil)
        {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
        }
        cell.textLabel.textColor = kRGB(205, 206, 207);
        cell.textLabel.font = kAppFont(Home_Small_Size+2);
        cell.detailTextLabel.font = kAppFont(Home_Small_Size);
        cell.detailTextLabel.textColor = kRGB(100, 99, 104);
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        switch (indexPath.row) {
            case 0:
            {
                cell.accessoryType = UITableViewCellAccessoryNone;
                cell.textLabel.text = @"任务名称";
                cell.detailTextLabel.text = [_dataDic valueForKey:@"InspectTaskName"];
            }
                break;
                //            case 1:
                //            {
                //                cell.accessoryType = UITableViewCellAccessoryNone;
                //                cell.textLabel.text = @"隐患类别";
                //                NSArray *arrayT = [[NSUserDefaults standardUserDefaults] objectForKey:select_RiskLevel];
                //                for (NSDictionary *yyy in arrayT) {
                //                    if ([[yyy valueForKey:@"Value"] intValue] == [[_dataDic valueForKey:@"RiskLevel"] intValue]) {
                //                        cell.detailTextLabel.text = [yyy valueForKey:@"Name"];
                //                    }
                //                }
                //                //cell.detailTextLabel.text = [NSString stringWithFormat:@"%d", [[_dataDic valueForKey:@"RiskType"] intValue]];
                //            }
                //                break;
            case 1:
            {
                cell.accessoryType = UITableViewCellAccessoryNone;
                cell.textLabel.text = @"检查专业";
                cell.detailTextLabel.text = [_dataDic valueForKey:@"InspectProfessionName"];
                
                //UIImageView *arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"02jiantou-"]];
                //arrowImageView.frame = CGRectMake(kDeviceWidth-16.0f-10.0f/2.0f, (54.0f-19.0f/2.0f)/2.0f, 10.0f/2.0f, 19.0f/2.0f);
                
                //cell.accessoryView = arrowImageView;
                
                //UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(16.0f, 53.5f, kDeviceWidth-16.0f, 0.5f)];
                //lineView.backgroundColor = kGreenColor;
                //[cell addSubview:lineView];
            }
                break;
            case 2:
            {
                cell.accessoryType = UITableViewCellAccessoryNone;
                cell.textLabel.text = @"检查项";
                cell.detailTextLabel.text = [_dataDic valueForKey:@"InspectItemName"];
            }
                break;
            case 3:
            {
                cell.accessoryType = UITableViewCellAccessoryNone;
                cell.textLabel.text = @"所属公司";
                cell.detailTextLabel.text = [_dataDic valueForKey:@"InspectOrgName"];//InspectOrgName
            }
                break;
            case 4:
            {
                cell.accessoryType = UITableViewCellAccessoryNone;
                cell.textLabel.text = @"所属项目部";
                cell.detailTextLabel.text = [_dataDic valueForKey:@"InspectProjectDPTName"];
            }
                break;
            case 5:
            {
                cell.accessoryType = UITableViewCellAccessoryNone;
                cell.textLabel.text = @"检查类型";
                NSArray *tempArray = [[NSUserDefaults standardUserDefaults] objectForKey:Check_Type_Items];
                for (NSDictionary *hhh in tempArray) {
                    if ([[hhh valueForKey:@"Value"] intValue] == [[_dataDic valueForKey:@"InspectType"] intValue]) {
                        cell.detailTextLabel.text = [hhh valueForKey:@"Name"];
                    }
                }
                //cell.detailTextLabel.text = [NSString stringWithFormat:@"%d", [[_dataDic valueForKey:@"InspectType"] intValue]];
            }
                break;
            case 6:
            {
                cell.accessoryType = UITableViewCellAccessoryNone;
                cell.textLabel.text = @"截止日期";
                NSString *dateStr = [_dataDic valueForKey:@"DeadLine"];
                dateStr = [dateStr stringByReplacingOccurrencesOfString:@"T" withString:@" "];
                cell.detailTextLabel.text = dateStr;//@"2016-06-06";
                
                UIImageView *arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"02jiantou-"]];
                arrowImageView.frame = CGRectMake(kDeviceWidth-16.0f-10.0f/2.0f, (54.0f-19.0f/2.0f)/2.0f, 10.0f/2.0f, 19.0f/2.0f);
                cell.accessoryView = arrowImageView;
                
                UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 53.5f, kDeviceWidth, 0.5f)];
                lineView.backgroundColor = kGreenColor;
                [cell addSubview:lineView];
                
            }
                break;
            default:
                break;
        }
        return cell;
    }else{
        //NSArray *sss = [_dataDic objectForKey:@"InspectTaskList"];
        
        static NSString *identifier = @"ToBeReviewedTaskDetailCell";
        ToBeReviewedTaskDetailCell *cell2 = (ToBeReviewedTaskDetailCell *)[tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell2 == nil)
        {
            cell2 = [[ToBeReviewedTaskDetailCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
        }
        cell2.textLabel.textColor = kRGB(205, 206, 207);
        cell2.textLabel.font = kAppFont(Home_Small_Size+2);
        cell2.detailTextLabel.font = kAppFont(Home_Small_Size);
        cell2.detailTextLabel.textColor = kRGB(100, 99, 104);
        cell2.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        
        [cell2.checkItemControl addTarget:self action:@selector(checkItemControlAction:) forControlEvents:UIControlEventTouchUpInside];
        cell2.checkItemControl.tag = indexPath.row;
        
        [cell2.seeBtn addTarget:self action:@selector(seeBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        cell2.seeBtn.tag = indexPath.row;
        
        [cell2.passBtn addTarget:self action:@selector(passBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        cell2.passBtn.tag = indexPath.row;
        
        [cell2.refuseBtn addTarget:self action:@selector(refuseBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        cell2.refuseBtn.tag = indexPath.row;
        
        
        
        NSDictionary *nnn = [bottomList objectAtIndex:indexPath.row];
        [cell2 showWithData:nnn];
        
        return cell2;
    }
    
    
    return nil;
}

- (void)seeBtnAction:(UIButton*)sender{
    //NSArray *sss = [_dataDic objectForKey:@"InspectTaskList"];
    NSDictionary *nnn = [bottomList objectAtIndex:sender.tag];
    
    WriteToBeReviewedTaskViewController *VC = [[WriteToBeReviewedTaskViewController alloc] initWithData:nnn InspectionID:[[_dataDic valueForKey:@"InspectionID"] intValue]];
    VC.delegate = self;
    VC.navTitle = @"详情";
    [self.navigationController pushViewController:VC animated:YES];
}
- (void)passBtnAction:(UIButton*)sender{
    //    NSArray *listA = [_dataDic objectForKey:@"InspectTaskList"];
    //    NSDictionary *kkkk;
    //    if (listA != nil && listA.count>0) {
    //        kkkk = [listA objectAtIndex:0];
    //    }
    
    //NSArray *sss = [_dataDic objectForKey:@"InspectTaskList"];
    NSDictionary *nnn = [bottomList objectAtIndex:sender.tag];
    
    NSDictionary *bodyD = [NSDictionary dictionaryWithObjectsAndKeys:
                           [[UserInfo getInstance] getUserID],@"UserID",
                           [NSNumber numberWithInt:[[_dataDic valueForKey:@"InspectionID"] intValue]],@"InspectionID",
                           [NSNumber numberWithInt:[[nnn valueForKey:@"InspectTaskID"] intValue]],@"InspectTaskID",
                           [_dataDic valueForKey:@"DeadLine"],@"DeadLine",
                           [nnn valueForKey:@"AuditDesc"],@"AuditDesc",
                           [NSNumber numberWithInt:0],@"AuditResult",//0通过 1 拒绝
                           nil];
    [[YMNetLib getInstance] connectWithAction:Get_AuditRepairRecord method:@"POST" withContent:@"" withBody:bodyD withDelegate:self];
    _currentStr = Get_AuditRepairRecord;
}
- (void)refuseBtnAction:(UIButton*)sender{
    //    NSArray *listA = [_dataDic objectForKey:@"InspectTaskList"];
    //    NSDictionary *kkkk;
    //    if (listA != nil && listA.count>0) {
    //        kkkk = [listA objectAtIndex:0];
    //    }
    
    //NSArray *sss = [_dataDic objectForKey:@"InspectTaskList"];
    NSDictionary *nnn = [bottomList objectAtIndex:sender.tag];
    
    NSDictionary *bodyD = [NSDictionary dictionaryWithObjectsAndKeys:
                           [[UserInfo getInstance] getUserID],@"UserID",
                           [NSNumber numberWithInt:[[_dataDic valueForKey:@"InspectionID"] intValue]],@"InspectionID",
                           [NSNumber numberWithInt:[[nnn valueForKey:@"InspectTaskID"] intValue]],@"InspectTaskID",
                           [_dataDic valueForKey:@"DeadLine"],@"DeadLine",
                           [nnn valueForKey:@"AuditDesc"],@"AuditDesc",
                           [NSNumber numberWithInt:1],@"AuditResult",//0通过 1 拒绝
                           nil];
    [[YMNetLib getInstance] connectWithAction:Get_AuditRepairRecord method:@"POST" withContent:@"" withBody:bodyD withDelegate:self];
    _currentStr = Get_AuditRepairRecord;
}


- (void)checkItemControlAction:(UIControl*)sender{
    //NSArray *sss = [_dataDic objectForKey:@"InspectTaskList"];
    NSDictionary *nnn = [bottomList objectAtIndex:sender.tag];
    
    WriteToBeReviewedTaskViewController *VC = [[WriteToBeReviewedTaskViewController alloc] initWithData:nnn InspectionID:[[_dataDic valueForKey:@"InspectionID"] intValue]];
    VC.delegate = self;
    VC.navTitle = @"详情";
    [self.navigationController pushViewController:VC animated:YES];
}

- (void)passValue:(NSDictionary *)data{
    //NSArray *sss = [_dataDic objectForKey:@"InspectTaskList"];
    NSMutableArray *rrrrr = [[NSMutableArray alloc] initWithArray:bottomList];
    for (int i = 0; i < rrrrr.count; i ++) {
        NSDictionary *aaaaa = [rrrrr objectAtIndex:i];
        if ([[data valueForKey:@"InspectTaskID"] intValue] == [[aaaaa valueForKey:@"InspectTaskID"] intValue]) {
            [rrrrr replaceObjectAtIndex:i withObject:data];
        }
    }
    bottomList = rrrrr;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return 54.0f;
    }else{
        return 54.0f*5.0f+10.0f;
    }
    return 0.0f;
}


#pragma mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
